package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Member;
import com.itheima.health.pojo.OrderDTO;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.MobileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * PROJECT_NAME: teamwork-health-system
 * NAME: MobileController
 * USER: zhang
 * DATE: 2023/6/6
 * DESCRIPTION :移动端Controller
 */
@RestController
@RequestMapping("/mobile")
@Slf4j
public class MobileController {

    @Resource
    private MobileService mobileService;

    /**
     * 查询全部套餐
     *
     * @return 全局通用返回信息Bean(套餐集合)
     */
    @GetMapping("/setmeal/getSetmeal")
    public Result selectAllSetmeal() {
        List<Setmeal> setmealList = mobileService.selectAllSetmeal();
        return new Result(Boolean.TRUE, MessageConst.GET_SETMEAL_LIST_SUCCESS, setmealList);
    }

    /**
     * 根据套餐Id查看套餐详情
     *
     * @param id 套餐Id
     * @return 全局通用返回信息Bean(Setmeal)
     */
    @GetMapping("/setmeal/findById")
    public Result selectSetmealById(Integer id) {
        Setmeal setmeal = mobileService.selectSetmealById(id);
        return new Result(Boolean.TRUE, MessageConst.QUERY_SETMEALLIST_SUCCESS, setmeal);
    }

    /**
     * 提交预约
     *
     * @param orderDTO 预约信息
     * @return {@link Result} 返回预约订单信息
     */
    @PostMapping("/order/submit")
    public Result submit(@RequestBody OrderDTO orderDTO) {
        return new Result(Boolean.TRUE, MessageConst.ORDER_SUCCESS, mobileService.submit(orderDTO));
    }

    /**
     * 通过id查询预约信息
     *
     * @param id 预约单id
     * @return {@link Result}
     */
    @GetMapping("/order/findById")
    public Result findById(Integer id){
        return new Result(Boolean.TRUE, MessageConst.QUERY_ORDER_SUCCESS,mobileService.getAllOrder(id));
    }
}
